<template>
	<view :style="type=='hr'?'padding-bottom:30rpx':''" class="content">
		<view class="block">
			<view class="company-item">
				<view class="text fw fs17">{{detail.enterpriseName}}</view>
				<view class="attention" v-if="identity==1&&detail.follow===0" @click="addLookMe">关注</view>
				<view class="attention1" v-if="identity==1&&detail.follow===1" @click="insertLookMe">已关注</view>
			</view>
			<view style="display: flex;flex-direction: row; margin-top: 16rpx;">
				<view class="icon-item"
					style="display: flex;flex-direction: row; margin-right: 20rpx;align-items: center;">
					<view class="iconfont icon-jibenziliao" style="color: #FF8888; font-size: 36rpx;font-weight: bold;">
					</view>
					<view class="text" style="font-size: 24rpx;">已认证营业执照</view>
				</view>
				<view class="icon-item" style="display: flex;flex-direction: row;align-items: center;">
					<view class="iconfont icon-wode" style="color: #79DEA2;font-weight: bold;"></view>
					<view class="text" style="font-size: 24rpx;">已认证手机号</view>
				</view>
			</view>
			<view class="form-label">
				<view class="form-title-label" v-if="form.isStateOwned>0">
					国有</view>
				<view class="form-title-label" v-if="form.isDomesticInvestment>0">
					内资</view>
				<view class="form-title-label" v-if="form.isGoOnTheMarket>0">
					上市</view>
			</view>
			<view class="text fs13 darkgray" style="display: flex; flex-direction: row;">
				<view class="text fs13 darkgray"> 甘肃酒泉 / </view>
				<view class="text fs13 darkgray" v-if="detail.enterpriseTypeText"> {{detail.enterpriseTypeText}} /
				</view>
				<view class="text fs13 darkgray" v-else> 暂无行业 / </view>
				<view class="text fs13 darkgray"> {{detail.scaleName}}</view>
			</view>
		</view>
		<view class="block">
			<view class="text fw fs15">公司介绍</view>
			<view class="text fs13 darkgray">{{detail.enterpriseIntroduction}}</view>

			<view class="text fw fs15">福利待遇</view>
			<view class="text fs13 darkgray">{{detail.welfare}}</view>

			<!-- <view class="text all fs13 fw">查看全部</view> -->
		</view>
		<view class="block list-block">
			<view class="text fw fs15" style="margin-bottom:10rpx;">热招职位</view>
			<view
				@click="navigate('/page_other/job_hunting/job_detail/index?id='+item.id+'&count='+count+'&jobType='+item.jobType)"
				class="list-item" v-for="(item,index) in jobPublishList" :key="item.id">
				<view class="list-info">
					<view class="title">{{item.jobTitle}}</view>
					<view class="address">{{item.jobAddress}}</view>
					<view class="label-block">
						<view class="label-item" v-for="label in item.welfareList">{{label}}</view>
					</view>
					<view class="wage" v-if="item.minSalary">{{item.minSalary}}-{{item.maxSalary}}<text class="unit">元</text></view>
					<view class="wage" v-else>面议</view>
				</view>
			</view>
		</view>
		<SuccessDialog v-if="showDialog" cancelText="查看我关注的企业" confirmText="继续找工作" @callback="dialogCallback">
			<slot style="display: flex;flex-direction: column;">
				<image :src="imageUrl+'/home/true.png'" style="width: 150rpx;height: 150rpx;">
				</image>
				<view style="color: #000;">关注成功！</view>
			</slot>
		</SuccessDialog>
	</view>
</template>

<script>
	import {
		insertLookMe
	} from '@/api/job_hunting.js'
	import {
		getEnterpriseDetailsApi
	} from '@/api/job.js';
	import SuccessDialog from '@/page_other/components/SuccessDialog/SuccessDialog.vue';
	export default {
		components: {
			SuccessDialog
		},
		data() {
			return {
				showDialog: false,
				sId: null,
				cId: null,
				type: null,
				count: 1,
				detail: {
					enterpriseName: '',
					enterpriseTypeText: '',
					scaleName: '',
					enterpriseIntroduction: '',

				},
				imageUrl: '',
				jobPublishList: []
			}
		},
		methods: {
			dialogCallback(e) {
				console.log(e);
				if (e) {
					this.showDialog = false;
				} else {
					uni.navigateTo({
						url: '/page_other/count_details/attention'
					})
					this.showDialog = false;
				}
			},
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			getEnterpriseDetails() {
				uni.showLoading({
					title: '加载中',
					mask: true,
				})
				getEnterpriseDetailsApi({
					sId: this.sId,
					cId: this.cId
				}).then((res) => {
					uni.hideLoading()
					this.detail = res
					this.jobPublishList = res.jobPublishList
				}).catch(() => {
					uni.hideLoading()
					this.showToast('加载失败', () => {
						uni.navigateBack()
					})
				})
			},
			addLookMe() {
				uni.showLoading({
					title: '关注中'
				})
				insertLookMe({
					eid: this.cId,
					userType: 1,
					lookMeType: 2,
					state: 2
				}).then((res) => {
					uni.hideLoading();
					this.showDialog = true;
					/*uni.showToast({
						title: '关注成功',
						icon: 'success'
					});*/
					this.getEnterpriseDetails();
				}).finally(() => {
					uni.hideLoading();
				})
			},
			insertLookMe() {
				uni.showLoading({
					title: '取消关注中'
				})
				insertLookMe({
					eid: this.cId,
					userType: 1,
					lookMeType: 2,
					state: 1
				}).then((res) => {
					uni.hideLoading();
					this.showToast('取消关注成功');
					this.getEnterpriseDetails();
				})
			},
			lookMe() {
				if(this.$store.getters.identity == 1)
				{
					insertLookMe({
						eid: this.cId,
						userType: 1,
						lookMeType: 1,
						state: 2
					}).then((res) => {}).catch(() => {
						console.log(res)
					})
				}

				
			},

		},
		computed: {
			identity() {
				return this.$store.getters.identity
			}
		},
		onLoad(e) {
			this.type = e.type;
			this.sId = e.sid;
			this.cId = e.cid;
			this.getEnterpriseDetails();
			this.imageUrl = this.globalConfig.imageUrl;
			this.lookMe()
		}
	}
</script>

<style lang="scss">
	$box-shadow: 0 0 10px 0 #efefef;

	.content {
		width: 100%;
		padding: 30rpx;
		background: #FAFAFA;
		position: relative;
		padding-bottom: 120rpx;

		.block {
			width: 100%;
			border-radius: 10rpx;
			background: #fff;
			box-shadow: $box-shadow;
			padding: 20rpx;

			view.text {
				line-height: 2.3;
			}

			.company-item {
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				align-items: center;

				.company-name {
					font-size: 42rpx;
					font-weight: bold;
					margin-right: 40rpx;
				}

				.attention {
					width: 120rpx;
					height: 45rpx;
					background: #FF7626;
					color: #fff;
					border-radius: 20rpx;
					text-align: center;
					font-size: 30rpx;
				}

				.attention1 {
					width: 120rpx;
					height: 45rpx;
					background: none;
					color: #FF7626;
					border: 2rpx solid #FF7626;
					border-radius: 20rpx;
					text-align: center;
					font-size: 30rpx;
				}
			}

			.form-label {
				display: flex;
				margin-top: 20rpx;

				.form-title-label {
					font-size: 12px;
					color: #0256FF;
					background-color: #CCDDFF;
					//border: 1rpx solid #CCDDFF;
					width: 120rpx;
					height: 40rpx;
					border-radius: 10rpx;
					text-align: center;
					padding-top: 3rpx;
					margin-right: 20rpx;
				}
			}

			margin-bottom:30rpx;

			.all {
				color: #FE7526;
			}

			.label-block {
				width: 100%;
				font-size: 24rpx;
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				justify-content: left;
				margin-top: 20rpx;

				.label-item {
					padding: 8rpx 12rpx;
					background: #F5F6F8;
					color: #999;
					margin: 0 30rpx 20rpx 0;
				}
			}
		}

		.block:last-child {
			margin-bottom: 0;
		}

		.block.list-block {
			box-shadow: none;
			display: flex;
			flex-direction: column;
			margin-bottom: 0;

			.list-item {
				width: 100%;
				background: #fff;
				border-radius: 10rpx;
				box-shadow: $box-shadow;
				padding: 20rpx;
				display: flex;
				flex-direction: row;
				justify-content: center;
				margin-bottom: 20rpx;

				.list-info {
					width: calc(100% - 0rpx);
					display: flex;
					flex-direction: column;

					view {
						width: 100%;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}

					.title {
						color: #000;
						font-weight: bold;
						font-size: 34rpx;
					}

					.address {
						color: #999;
						font-size: 26rpx;
						margin-top: 20rpx;
					}

					.label-block {
						font-size: 24rpx;
						display: flex;
						flex-direction: row;
						flex-wrap: wrap;
						justify-content: left;
						margin-top: 20rpx;

						.label-item {
							padding: 8rpx 20rpx;
							background: #F5F6F8;
							color: #999;
							margin: 0 10rpx 20rpx 0;
						}
					}

					.wage {
						color: #FE7526;
						font-size: 36rpx;
						font-weight: bold;

						.unit {
							font-size: 28rpx;
							font-weight: normal;
						}
					}
				}
			}

			.list-item:last-child {
				margin-bottom: 0;
			}
		}

	}
</style>